package com.fy.paper.controller;

import com.fy.core.vo.ApiRest;
import com.fy.paper.dto.FillAnswerDto;
import com.fy.paper.service.PaperService;
import com.fy.paper.vo.DtkVo;
import com.fy.paper.vo.PaperQuDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 试卷 前端控制器
 * </p>
 *
 * @author 
 * @since 2023-06-16
 */
@RestController
@RequestMapping("/paper")
@CrossOrigin
public class PaperController {

    @Autowired
    private PaperService paperService;

    //根据考试id创建试卷
    @GetMapping("create/{examId}")
    public ApiRest create(@PathVariable String examId){

        return paperService.create(examId);

    }

    @GetMapping("dtk/{paperId}")
    public ApiRest<DtkVo> dtk(@PathVariable String paperId){
        return paperService.dtk(paperId);
    }

    @GetMapping("qu/detail/{paperId}/{quId}")
    public ApiRest<PaperQuDetail> detail(@PathVariable String paperId,
                                         @PathVariable String quId){
        return paperService.paperQuDetail(paperId,quId);
    }

    @PostMapping("fillAnswer")
    public ApiRest fillAnswer(@RequestBody FillAnswerDto fillAnswerDto){
        return paperService.fillAnswer(fillAnswerDto);
    }

    @GetMapping("handlePaper/{paperId}")
    public ApiRest handlePaper(@PathVariable String paperId){

        return paperService.handlePaper(paperId);
    }

}
